
************ Table S1
ssc install texsave, replace
loc run = 0
if `run' == 1{
use  ..\temp\trade_data_h6_covars_h1.dta, clear
collapse (min) B1_min=B1 (p25) B1_p25=B1 (p50) B1_p50=B1 (p75) B1_p75=B1 (max) B1_max=B1 (mean) B1_avg=B1, by(countryname c y *_orig)

bys countryname c : egen min_year=min(y)
bys countryname c : egen max_year=max(y)

collapse (mean) min_year max_year B1_min  B1_p25  B1_p50 B1_p75  B1_max B1_avg commodity_exports_orig fuel_exports_orig ores_metal_exports_orig food_exports_orig, by(countryname c y)
collapse (mean) min_year max_year B1_min  B1_p25  B1_p50 B1_p75  B1_max B1_avg commodity_exports_orig fuel_exports_orig ores_metal_exports_orig food_exports_orig, by(countryname c)

foreach var of varlist min_year max_year B1_min  B1_p25  B1_p50 B1_p75  B1_max B1_avg {
replace  `var' = int(`var')	
}

format %15.0fc B1_min  B1_p25  B1_p50 B1_p75  B1_max B1_avg
format %15.2fc  commodity_exports_orig fuel_exports_orig ores_metal_exports_orig food_exports_orig

gsort countryname
gen count = _n
label var count "No."
export excel using ..\output\TableS1.xls, firstrow(variables) replace
keep count countryname min_year max_year B1_p50 B1_avg commodity_exports_orig fuel_exports_orig ores_metal_exports_orig food_exports_orig
order count countryname min_year max_year B1_p50 B1_avg commodity_exports_orig fuel_exports_orig  ores_metal_exports_orig food_exports_orig
texsave * using ..\output\TableS1.tex,  replace
}

***************Table S2
loc run = 1
if `run' == 1{
use  ..\temp\trade_data_h6_covars_h1.dta, clear
global evasion "gap_evasion_imp_customs"
replace $evasion = . if exp_reported==0 

keep commodity_exports_orig fuel_exports_orig ores_metal_exports_orig food_exports_orig compriceindexfixw_orig tf_best_adv  ntm_EF $evasion loggdppc_orig cce rqe gini_i_orig 

foreach var of varlist commodity_exports_orig fuel_exports_orig ores_metal_exports_orig food_exports_orig compriceindexfixw_orig tf_best_adv ntm_EF $evasion loggdppc_orig cce rqe gini_i_orig {
	gen mean_`var' = `var'
	gen sd_`var' = `var'
}

collapse (mean) mean_* (sd) sd_*
gen id = 1
reshape long mean_ sd_, i(id) j(var) string
drop id

gen order = .

replace order = 1 if var == "commodity_exports_orig"
replace var = "Commodity export share" if var == "commodity_exports_orig"

replace order = 2 if var == "food_exports_orig"
replace var = "Food export share " if var == "commodity_exports_orig"

replace order = 3 if var == "fuel_exports_orig"
replace var = "Fuel export share" if var == "fuel_exports_orig"

replace order = 4 if var == "ores_metal_exports_orig"
replace var = "Ores and metals export share" if var == "ores_metal_exports_orig"

replace order = 5 if var == "compriceindexfixw_orig"
replace var = "Commodity price index (1=2012)" if var == "compriceindexfixw_orig"

replace order = 6 if var == "loggdppc_orig"
replace var = "Log GDP per capita" if var == "loggdppc_orig"

replace order = 7 if var == "gini_i_orig"
replace var = "Gini coefficient" if var == "gini_i_orig"

replace order = 8 if var == "cce"
replace var = "Control of corruption" if var == "cce"
 
replace order = 9 if var ==  "rqe"
replace var = "Regulatory quality" if var ==  "rqe"

replace order = 10 if var == "tf_best_adv"
replace var = "Tariff, applied" if var == "tf_best_adv"

replace order = 11 if var == "ntm_EF"
replace var = "NTM = 1, Chapter E or F" if var == "ntm_EF"

replace order = 12 if var == "gap_evasion_imp_customs"
replace var = "Evasion gap" if var == "gap_evasion_imp_customs"


gsort + order
format mean_ sd_ %9.2f
drop order

texsave * using ..\output\TableS2.tex,  replace	
}